#include "multidatasui.h"
#include "ui_multidatasui.h"

#include <QLabel>
#include <QPixmap>

MultiDatasUI::MultiDatasUI(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MultiDatasUI)
{
    ui->setupUi(this);
}

MultiDatasUI::~MultiDatasUI()
{
    delete ui;
}

void MultiDatasUI::setData(const QStringList &upData, const QStringList &downData) {
    // 设置上半部分
    for (int i = 0; i < 7; ++i) {
        QLabel* up = findChild<QLabel*>(QString("upLb%1").arg(i));
        if (up) {
            up->setText(upData[i]);
            up->setAlignment(Qt::AlignCenter);
        }
    }

    // 设置下半部分
    for (int i = 0; i < 7; ++i) {
        QLabel* down = findChild<QLabel*>(QString("downLb%1").arg(i));
        if (down) {
            down->setText(downData[i]);
            down->setAlignment(Qt::AlignCenter);
        }
    }
}

void MultiDatasUI::setIconData(const QList<QPixmap> &icons, const QStringList &downData) {
    // 设置图标
    for(int i = 0; i < 7; ++i) {
        QLabel* up = findChild<QLabel*>(QString("upLb%1").arg(i));
        if (up && i < icons.size()) {
            up->setPixmap(icons[i].scaled(30, 30, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
            up->setAlignment(Qt::AlignCenter);
        }
    }

    // 设置下半部分
    for (int i = 0; i < 7; ++i) {
        QLabel* down = findChild<QLabel*>(QString("downLb%1").arg(i));
        if (down) {
            down->setText(downData[i]);
            down->setAlignment(Qt::AlignCenter);
        }
    }
}
